package vip.meeet.algorithm.arr;


public class Num53 {

    public static void main(String[] args) {
        int[] a = {1,2,3,0,0,0};
        int[] b = {2,5,6};



    }

    public int maxSubArray(int[] nums) {
        if(nums.length == 0){
            return 0;
        }
        int[] maxi = new int[nums.length];
        int max = nums[0];
        maxi[0] = nums[0];
        for(int i=1;i<nums.length;i++){
            if(maxi[i-1] > 0){
                maxi[i] = maxi[i-1] + nums[i];
            }else {
                maxi[i] = nums[i];
            }
            if(maxi[i] > max){
                max = maxi[i];
            }
        }
        return max;
    }


}
